<?php
include_once 'config.php';
$username = 'tungt'; 
function get_list_residual_stock($username,$DB_NAME){
	$db=new SQLiteDatabase($DB_NAME);
	$real_name= sqlite_escape_string($username);
	$result=$db->query("SELECT * FROM residual_stock where username='$real_name' order by stock ASC");
	$rs = array();
	while($result->valid()) {
		$row=$result->current();
		$rs[] =$row;
		$result->next();
	}
	return $rs;
} 
$rs = get_list_residual_stock($username, $DB_NAME);
?>
<table border="1">
	<thead>
		<tr>
			<th scope="col">stock</th>
			<th scope="col">value</th>
			<th scope="col">quality</th>
			<th scope="col">total</th>
		</tr>
	</thead>
	<tbody>
		<?php
	foreach ($rs as $r) {
		echo "<tr>
			<td>".$r['stock']."</td>
			<td>".number_format($r['value'])."</td>
			<td>".number_format($r['quality'])."</td>
			<td>".number_format($r['value']*$r['quality'])."</td>
		</tr>";
	} 
		?>
	</tbody>
</table>
